package com.example.edf_jimmy;

import java.util.ArrayList;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.ListView;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;


public class Afficheclient extends Activity {

	private ListView lvListe;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_afficheclient);
		
		Modele vmodele = new Modele();
		vmodele.open();
		final ArrayList<Client> malistec = vmodele.listClient();
		vmodele.close();
		lvListe = (ListView)findViewById(R.id.lvListe);
		
		ClientAdapter adapter = new ClientAdapter(this, malistec);
		lvListe.setAdapter(adapter);
		
		lvListe.setOnItemClickListener(new OnItemClickListener() {
			@Override
		      public void onItemClick(AdapterView<?> a, View v, int position, long id) {
			
				Intent myIntent = new Intent(getApplicationContext(), Modifclient.class);
				myIntent.putExtra("Identifiant", malistec.get(position).getIdentifiant());
				startActivity(myIntent);

				
		        	}
		         });
		}

		         
	


	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.afficheclient, menu);
		return true;
	}
	

}
